<?php
/**
 * This file should be execute once, all file will be rename,
 * by keeping only the timestamp part of the file name
 * 
 */
use Fox\Html\CheckBox;
use Fox\Html\Input;
use Fox\Html\Block;
use Fox\Html\Screen;
$screen = new Screen('exe','execute');
$bl = new Block('b');
$bl->add(new CheckBox('commit'));
$screen->add($bl);
if($screen->submitted()) {
	
	$fields = $screen->get();
	$commit = $fields['commit'];
	if ($handle = opendir(_TEMP_)) {
	    /* This is the correct way to loop over the directory. */
	    while (false !== ($entry = readdir($handle))) {
	       if($entry != '.' && $entry != '..') {
	        $newName = substr($entry,0,10).'.'.substr($entry, strrpos($entry, '.') + 1);
	        echo "$entry -> $newName<br>";
	        if($commit) {
	        	$oldfilepath = _TEMP_.DIRECTORY_SEPARATOR.$entry;
	        	copy($oldfilepath,_DOCUMENTS_.DIRECTORY_SEPARATOR.$newName);
	        }
	       }
	    }
	    closedir($handle);
	}

}
echo $screen->display();